﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LunarSF.SHomeWorkshop.LunarMarkdownEditor.Utils
{
    public static class LFile
    {
        /// <summary>
        /// if file1's LastWriteTime is newer than file2's , return true.
        /// </summary>
        /// <returns></returns>
        public static bool IsNewerThanAnotherFile(this string fileFullPath1, string fileFullPath2)
        {
            try
            {
                if (System.IO.File.Exists(fileFullPath1) != true) return false;
                if (System.IO.File.Exists(fileFullPath2) != true) return false;

                FileInfo fi1 = new FileInfo(fileFullPath1);
                FileInfo fi2 = new FileInfo(fileFullPath2);
                return fi1.LastWriteTime.CompareTo(fi2.LastWriteTime) > 0;
            }
            catch
            {
                return false;
            }
        }

        public static bool FileExist(this string fileFullPath)
        {
            return System.IO.File.Exists(fileFullPath);
        }
    }
}
